package com.yami.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yami.shop.bean.model.LuckProduct;
import com.yami.shop.bean.model.LuckUserProduct;
import com.yami.shop.dao.LuckUserProductMapper;
import com.yami.shop.service.LuckUserProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class LuckUserProductServiceImpl extends ServiceImpl<LuckUserProductMapper,LuckUserProduct> implements LuckUserProductService {

    @Autowired
    private LuckUserProductMapper luckUserProductMapper;

    @Override
    public List<Map<String,Object>> getAllLuckPerson(){
       return   luckUserProductMapper.getAllLuckPerson();
    }

    @Override
    public LuckUserProduct selectByUid(String uid){
        return luckUserProductMapper.selectByUid(uid);
    }

    @Override
    public LuckUserProduct getLuckUserProd(LuckUserProduct luckUserProduct) {
        return luckUserProductMapper.getLuckUserProd(luckUserProduct);
    }

    @Override
    public int getWinningTimes(LuckProduct luckProduct) {
        LuckUserProduct luckUserProduct = new LuckUserProduct();
        luckUserProduct.setPname(luckProduct.getName());
        luckUserProduct.setShopId(luckProduct.getShopId());
        luckUserProduct.setLtime(new Date());
        return luckUserProductMapper.getWinningTimes(luckUserProduct);
    }

    @Override
    public int getAllLuckTime(String userId, Long shopId) {
        return luckUserProductMapper.getAllLuckTime(userId, shopId);
    }

    @Override
    public int getAllWinningTime(String userId, Long shopId) {
        return luckUserProductMapper.getAllWinningTime(userId, shopId);
    }

    @Override
    public int getcurrentDayLuckTime(String userId, Long shopId) {
        LuckUserProduct luckUserProduct = new LuckUserProduct();
        luckUserProduct.setShopId(shopId);
        luckUserProduct.setUid(userId);
        luckUserProduct.setLtime(new Date());
        return luckUserProductMapper.getcurrentDayLuckTime(luckUserProduct);
    }

    @Override
    public int getdayWinningTime(String userId, Long shopId) {
        LuckUserProduct luckUserProduct = new LuckUserProduct();
        luckUserProduct.setShopId(shopId);
        luckUserProduct.setUid(userId);
        luckUserProduct.setLtime(new Date());
        return luckUserProductMapper.getdayWinningTime(luckUserProduct);
    }
}
